﻿<!doctype html>
<html class="no-js">
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="description" content="">
  <meta name="keywords" content="">
  <meta name="viewport"
        content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
  <title>车生活</title>

  <!-- Set render engine for 360 browser -->
  <meta name="renderer" content="webkit">

  <!-- No Baidu Siteapp-->
  <meta http-equiv="Cache-Control" content="no-siteapp"/>

  <link rel="icon" type="image/png" href="assets/i/favicon.png">

  <!-- Add to homescreen for Chrome on Android -->
  <meta name="mobile-web-app-capable" content="yes">
  <link rel="icon" sizes="192x192" href="assets/i/app-icon72x72@2x.png">

  <!-- Add to homescreen for Safari on iOS -->
  <meta name="apple-mobile-web-app-capable" content="yes">
  <meta name="apple-mobile-web-app-status-bar-style" content="black">
  <meta name="apple-mobile-web-app-title" content="车生活"/>
  <link rel="apple-touch-icon-precomposed" href="assets/i/app-icon72x72@2x.png">

  <link rel="stylesheet" href="assets/css/amazeui.min.css">
  <link rel="stylesheet" href="assets/css/app.css">
</head>
<body>

<header data-am-widget="header" class="am-header am-header-default am-header-fixed">
  <div class="am-header-left am-header-nav">
    <a href="javascript:history.go(-1)" class="">
      <i class="am-header-icon am-icon-chevron-left"></i>
    </a>
  </div>
  <h1 class="am-header-title">
    <a href="#title-link" class="">年审查询</a>
  </h1>
   <div class="am-header-right am-header-nav">
    <a href="javascript: void(0)"  id="nav_click" class="">
      <i class="am-menu-toggle-icon am-icon-th-large am-icon-sm"></i>
    </a>
  </div>
</header>

<div style="height: 20px;"></div>
<form action="#"  class="am-form" id="doc-vld-msg">
  <div class="am-g">
    <div class="am-u-sm-12">    
      <div class="am-input-group am-form-group am-input-group-default"><span class="am-input-group-label">车型选择</span>
        <SELECT name="cllx" id="cllx">
          <OPTION value="1">营运客车</OPTION>
          <OPTION value="2">货车,大中型客车</OPTION>
          <OPTION value="3">7座以下非营运小客车</OPTION>
          <OPTION value="6">面包车和7座（含）以上非营运小客车</OPTION>
          <OPTION value="4">摩托车</OPTION>
          <OPTION value="5">其他机动车</OPTION>
        </SELECT>
      </div>
    </div>

    <div class="am-u-sm-12">    
      <div class="am-input-group am-form-group am-input-group-default"><span class="am-input-group-label">注册日期</span>
        <input type="text"  data-validation-message="*请选择正确的注册日期" class="am-form-field" style="background:#fff" placeholder="请选择注册登记日期"  id="appDate" readonly />
      </div>
    </div>

    <div class="am-u-sm-12"> 
          <div class="am-input-group am-form-group am-input-group-default"><span class="am-input-group-label ">事故情况</span>   
            <SELECT name="sgqk" id="sgqk">
              <OPTION value="0" selected>未发生过致人伤亡事故</OPTION>
              <OPTION value="1">发生过致人伤亡事故</OPTION>
            </SELECT>
        </div>
    </div>    
 

    <div class="am-u-sm-12">    
      <div class="am-form-group">
        <a href="javascript: void(0)" data-am-modal="{target: '#xszsm', closeViaDimmer: 0, width: '320', height: 220}">*注册日期在行驶证上，不明点我</a>
      </div>
    </div> 

    <div class="am-modal am-modal-no-btn" tabindex="-1" id="xszsm">
      <div class="am-modal-dialog">
        <div class="am-modal-hd">行驶证样板
          <a href="javascript: void(0)" class="am-close am-close-spin" data-am-modal-close>&times;</a>
        </div>
        <div class="am-modal-bd">
          <img src="assets/i/xszzc.jpg" style="width:100%">
        </div>
      </div>
    </div>

    <div class="am-u-sm-12">    
      <button class="am-btn am-btn-success am-radius am-btn-block" onclick="search()" type="button">立即查询</button>
    </div>    
  </div>

  <div class="am-u-sm-12">
  <div class="am-panel-hd am-text-xs">
    备注：<br/>
    一、如果购车后4年未登记的，不属于免检范围。<br/>
    二、办理车检时需提供：
    ① 机动车行驶证；
    ② 交通事故责任强制保险 、车船税证明；
    ③ 请处理完交通违法和交通事故。<br/>
    * 查询结果供参考
  </div>
  </div>
</form>

<input type="hidden" data-am-modal="{target: '#my-popup', closeViaDimmer: 0, width: 320, height: 270}" id="hideclick" />

<div id="appDatetext" style="position:fixed;width:40%;left:30%;top:20%;margin-left:width/2;margin-top:height/2;display:none;z-index:9999">
<button type="button" class="am-btn am-btn-danger am-round am-btn-block"><span id="showtext">请选择注册日期！</span></button>
</div>

<div class="am-modal am-modal-no-btn" id="my-popup">
  <div class="am-modal-dialog">
    <div class="am-modal-hd">查询结果
            <span data-am-modal-close class="am-close am-close-alt am-icon-times"></span>
    </div>
    <div class="am-modal-bd">
    <hr data-am-widget="divider" style="" class="am-divider am-divider-default"
/>
      <div id="result" class="am-text-left">                            
        <div id="rq1">&nbsp;&nbsp;您的爱车<span class="am-text-success am-text-lg">属于</span>6年内免检车辆。<BR>&nbsp;&nbsp;本轮检验周期内，请于<SPAN id="jybzrq"></SPAN>前携带相关材料到车管所为爱车领取检验标志。</div>
        <div id="rq2">&nbsp;&nbsp;您的爱车<span class="am-text-danger am-text-lg">不属于</span>6年内免检车辆。<BR>&nbsp;&nbsp;本轮检验周期内，请于<SPAN id="jyrq"></SPAN>前至检验机构参加安全技术检验。</div>
      </div>
            <div style="height:20px"></div>
      <div><div id="daibantext"></div></div>
    </div>
  </div>

</div>
<script type="text/x-handlebars-template" id="amz-tpl">
  {{>menu menu}}
  {{>list_news list1}}
  {{>list_news list2}}
  {{>footer footer}}
  {{>navbar navbar}}
</script>
<script src="assets/js/jquery.min.js"></script>
<script src="assets/js/amazeui.min.js"></script>
<script src="assets/js/handlebars.min.js"></script>
<script src="assets/js/amazeui.widgets.helper.js"></script>
<script src="assets/js/app.js"></script>
<script type="text/javascript">
  $(function(){	  
    var nowTemp = new Date();
    var now = new Date(nowTemp.getFullYear(), nowTemp.getMonth(), nowTemp.getDate(), 0, 0, 0, 0);
    var bottomdate= new Date(1994, 12, 1, 0, 0, 0, 0);
    var $myStart2 = $('#appDate');

    var checkin = $myStart2.datepicker({
      onRender: function(date) {
        return (date.valueOf() > now.valueOf() || date.valueOf() < bottomdate.valueOf() ) ? 'am-disabled' : '';
      }
    }).on('changeDate.datepicker.amui', function(ev) {
        checkin.close();
    }).data('amui.datepicker');

    
  $('#doc-vld-msg').validator({
    onValid: function(validity) {
      $(validity.field).closest('.am-form-group').find('.am-alert').hide();
    },

    onInValid: function(validity) {
      var $field = $(validity.field);
      var $group = $field.closest('.am-form-group');
      var $alert = $group.find('.am-alert');
      // 使用自定义的提示信息 或 插件内置的提示信息
      var msg = $field.data('validationMessage') || this.getValidationMessage(validity);

      if (!$alert.length) {
        $alert = $('<div  class="am-alert am-alert-danger"></div>').hide().
          appendTo($group);
      }

      $alert.html(msg).show();
    }
  });
});

function search() {
        var cllx = $("#cllx").val();
        if ($("#appDate").val() == "") {
          $("#appDatetext").show();
          setTimeout("$('#appDatetext').fadeOut(1000)",1000);
          return;
        }
        var ccdjrq = new Date($("#appDate").val().replace(/-/g, "/"));
        var sgqk = $("#sgqk").val();
        var sysDate = new Date(), day = new Date(), lastday = new Date();

        if (cllx == "1") {
                //取5年内的最后一天比较
                lastday = cal_lastday(ccdjrq, 5);
                if (sysDate <= lastday) {
                        cal_jyqz(ccdjrq, sysDate, 12, 0);
                        return;
                }
                //每6个月检验一次
                cal_jyqz(ccdjrq, sysDate, 6, 0);
                return;
        }

        if (cllx == "2") {
                //取10年内的最后一天比较
                lastday = cal_lastday(ccdjrq, 10);
                if (sysDate <= lastday) {
                        cal_jyqz(ccdjrq, sysDate, 12, 0);
                        return;
                }
                //每6个月检验一次
                cal_jyqz(ccdjrq, sysDate, 6, 0);
                return;
        }

        if (cllx == "3") {
                //取6年内的最后一天比较
                lastday = cal_lastday(ccdjrq, 6);

                if (sysDate <= lastday) {
                        if (sgqk == "0" && ccdjrq >= new Date("2010/09/01"))
                                cal_jyqz(ccdjrq, sysDate, 24, 1);
                        else
                                cal_jyqz(ccdjrq, sysDate, 24, 0);

                        return;
                }
                //15年内
                lastday = cal_lastday(ccdjrq, 15);
                if (sysDate <= lastday) {
                        cal_jyqz(ccdjrq, sysDate, 12, 0);
                        return;
                }
                //每6个月检验一次
                cal_jyqz(ccdjrq, sysDate, 6, 0);
                return;
        }

        if (cllx == "4") {
                //取6年内的最后一天比较
                lastday = cal_lastday(ccdjrq, 4);
                if (sysDate <= lastday) {
                        cal_jyqz(ccdjrq, sysDate, 24, 0);
                        return;
                }
                cal_jyqz(ccdjrq, sysDate, 12, 0);
                return;
        }

        if (cllx == "5") {
                cal_jyqz(ccdjrq, sysDate, 12, 0);
                return;
        }

        if (cllx == "6") {
                //取6年内的最后一天比较
                lastday = cal_lastday(ccdjrq, 6);
                if (sysDate <= lastday) {
                        cal_jyqz(ccdjrq, sysDate, 24, 0);
                        return;
                }
                //15年内
                lastday = cal_lastday(ccdjrq, 15);
                if (sysDate <= lastday) {
                        cal_jyqz(ccdjrq, sysDate, 12, 0);
                        return;
                }
                //每6个月检验一次
                cal_jyqz(ccdjrq, sysDate, 6, 0);
                return;
        }
}

function cal_jyqz(ccdjrq, sysDate, interval, sfmj) {
        var day = new Date();
        if (sysDate.getFullYear() == ccdjrq.getFullYear() && sysDate.getMonth() == ccdjrq.getMonth())
                day = new Date(sysDate.getFullYear() + interval / 12, sysDate.getMonth() + 1, 1);
        else
                day = new Date(sysDate.getFullYear(), sysDate.getMonth()
                        + (12 * (sysDate.getFullYear() - ccdjrq.getFullYear() + 2)
                        + ccdjrq.getMonth() - sysDate.getMonth()) % interval
                        + 1, 1);

        var last = new Date(day - 86400000);

        if (last >= new Date("2014/09/01") && sfmj == "1") {
                $("#jybzrq").html(
                                last.getFullYear() + "年" + (last.getMonth() + 1) + "月"
                                + last.getDate() + "日");
                $("#rq1").css('display', '');
                $("#rq2").css('display', 'none');
                $("#daibantext").html("<a href='nsdl.html' style='color:white'><button type='button' class='am-btn am-radius am-btn-success  am-btn-block'>我没空，申请代领</button></a>");
        }
        else {
                $("#jyrq").html(
                                last.getFullYear() + "年" + (last.getMonth() + 1) + "月"
                                + last.getDate() + "日");
                $("#rq2").css('display', '');
                $("#rq1").css('display', 'none');
                $("#daibantext").html("<a href='nsyy.html' style='color:white'><button type='button' class='am-btn am-radius am-btn-success  am-btn-block'>我要预约代办年审</button></a>");                
        }
        $("#result").css('display', 'block');
        $("#hideclick").click();
}

function cal_lastday(ccdjrq, year) {
        return new Date(new Date(ccdjrq.getFullYear() + year,
                        ccdjrq.getMonth() + 1, 1) - 86400000);
}
</script>
<!--<![endif]-->

</body>
</html>
